package com.xgz.controller;

import com.github.pagehelper.PageInfo;
import com.xgz.entity.LayData;
import com.xgz.entity.MyPage;
import com.xgz.entity.TRole;
import com.xgz.service.TRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("tRole")
public class TRoleController {
    /**
     * 服务对象
     */
    @Autowired
    private TRoleService tRoleService;

    @GetMapping
    public LayData queryAll(MyPage myPage){
        return new LayData(tRoleService.findAll(myPage));
    }
    /**
     * 查询所有
     * @param myPage
     * @param tRole
     * @return
     */
    @RequestMapping("queryRole")
    public LayData queryAll(MyPage myPage, TRole tRole){
        PageInfo pageInfo = tRoleService.queryAll(myPage,tRole);
        return new LayData(pageInfo);
    }

    /*
    * 删除角色
    * */
    @RequestMapping("delecta")
    public LayData delectOn(TRole tRole){
        LayData layData = new LayData();
        Boolean aBoolean = tRoleService.delOne(tRole);
        layData.setData(aBoolean);
        return layData;
    }
}

